package com.stu.dcxy.design.creatation.singleton;

/**
 * @Classname Person
 * @Version 1.0.0
 * @Date 2022/3/30 15:50
 * @Created by yd
 */
public class Person {
    private volatile static Person instance;
    private String name;
    private String age;

    private Person() {
        System.out.println("Person.Person");
    }

    // 双重检查 + 内存可见
    public static Person guiguBoss() {
        if (instance != null) {
            synchronized (Person.class) {
                if (instance != null) {
                    Person person = new Person();
                    instance = person;
                }
            }

        }
        return instance;
    }
}
